//
//  LandMarkList.swift
//  MacLandmarks
//
//  Created by taic8cai on 2020/6/29.
//  Copyright © 2020 Apple. All rights reserved.
//

import SwiftUI

struct LandMarkList: View {
    @EnvironmentObject var userData: UserData
    
    @Binding var selectedLandMark: Landmark?
    
    var body: some View {
        List {
            ForEach(userData.landmarks) { landmark in
                if (!self.userData.showFavoritesOnly || landmark.isFavorite) {
                    LandmarkRow(landmark: landmark).tag(landmark)
                }
                
            }
        }
    }
}

struct LandMarkList_Previews: PreviewProvider {
    static var previews: some View {
        LandMarkList(selectedLandMark: .constant(landmarkData[0])).environmentObject(UserData())
    }
}
